<?php if( $tpl['_header'] ){ include($_CFG['DIR_ADMIN_TPL'].'header.html'); }?>


<?php if( $tpl['_body'] == 'backup' ){ ?>
    <form id="wfm-dbbackup-fill" onkeydown="deal_wfm_keyboard(event,this);">
        <div class="table-header"><i></i><span>备份类型&nbsp;</span></div>
        <div class="listtable-data" style="border-bottom:0;">
            <table class="listtable-table">
            <tr>
                <td width="120" style="padding-left:5px;">
                    <input type="radio" name="backup_type" value="full" id="wfmc-dbbackup-backtype-all" checked="checked" class="radio" 
                    onclick="document.getElementById('wfm-dbbackup-dbtablebox').style.display='none'"/><label for="wfmc-dbbackup-backtype-all">全部备份</label>
                </td>
                <td style="color:#999">&nbsp;备份数据库所有表</td>
            </tr>
            <tr>
                <td style="padding-left:5px;">
                    <input type="radio" name="backup_type" value="custom" id="wfmc-dbbackup-backtype-custom" class="radio" 
                    onclick="document.getElementById('wfm-dbbackup-dbtablebox').style.display=''"/><label for="wfmc-dbbackup-backtype-custom">自定义备份</label>
                </td>
                <td style="color:#999">&nbsp;根据自行选择备份数据表</td>
            </tr>
            <tr style="display:none" id="wfm-dbbackup-dbtablebox">
                <td colspan="2">
                    <table width="100%">
                    <tr>
                        <td style="padding-left:4px; border:0;">
                            <input type="checkbox" id="wfm-dbbackup-selall" onclick="Formc.cbSyncCbg(this,Formc.cbgByContainer('wfm-dbbackup-customtable'))" class="checkbox"/>
                            <label for="wfm-dbbackup-selall"><b>全选</b></label>
                        </td>
                    </tr>
                    <tr><td id="wfm-dbbackup-customtable" style="padding-left:4px; border-bottom:0;"><?php echo $tpl['cbg_custom_table']; ?></td></tr>
                    </table>
                </td>
            </tr>
            </table>
        </div>

        <div class="table-header"><i></i><span>其他选项&nbsp;</span></div>
        <div class="listtable-data" style="border-bottom:0;">
            <table class="listtable-table">
            <tr>
                <td width="170" style="padding-left:10px;">数据插入</td>
                <td>
                    <input type="checkbox" name="columns" id="wfmc-dbbackup-columns" value="1" class="checkbox" checked="checked"/><label 
                    for="wfmc-dbbackup-columns">显示字段</label>
                    <input type="checkbox" name="extended" id="wfmc-dbbackup-extended" value="1" class="checkbox"/><label 
                    for="wfmc-dbbackup-extended">扩展插入</label>
                </td>
            </tr>
            <tr>
                <td style="padding-left:10px;">分卷备份 - 文件长度限制(KB)</td>
                <td>&nbsp;<input type="text" name="volsize" value="1536" class="fillbox" style="width:155px"/></td>
            </tr>
            <tr>
                <td style="padding-left:10px;">备份文件名</td>
                <td>&nbsp;<input type="text" name="sqlfname" value="<?php e($tpl['sqlfname'],'formc'); ?>" class="fillbox" style="width:155px"/></td>
            </tr>
            </table>
        </div>
    </form>


<?php }elseif( $tpl['_body'] == 'index' || $tpl['_body'] == 'list' ){ ?>

    <?php if( $tpl['_body'] == 'index' ){?>
    <div class="tabitem-box" id="tabitem-dbbackup" onclick="tabbar(this.id,'tabbody-dbbackup',event)"><i class="icon"></i>
        <span class="on">&nbsp;服务器上的文件</span><span>上传SQL文件</span>
    </div>
    <div id="tabbody-dbbackup">
    <?php }?>

        <?php if( $tpl['_bodysub'] != 'query' ){?>
        <div class="listtable-div" id="listtable-dbbackup" onmouseover="ListTable.init(this.id,'modules/db/db_backup.php','?act=list');">
            <div class="listtable-data">
        <?php }?>

                <table class="listtable-table" onmouseover="TableAct.moveHiLight(this);TableAct.choiceHiLight(this);">
                <tr>
                    <th width="5%"><input type="checkbox" id="listtable-dbbackup-touch" class="checkbox" onclick="ListTable.achoice(this.checked,this,'listtable-dbbackup-ids')"/></th>
                    <th width="29%">文件名</th>
                    <th width="19%">备份时间</th>
                    <th width="14%">大小</th>
                    <th width="12%">卷</th>
                    <th width="21%">操作</th>
                </tr>
                <?php if( $tpl['error'] ){?>
                <tr><td colspan="6"><div class="tips-div"><span><?php echo $tpl['error']; ?></span></div></td></tr>
                <?php }else{?>
                    <?php if( !empty($tpl['all']) ){ foreach( $tpl['all'] AS $r ){?>
                    <tr class="<?php echo $r['type']=='volumes' ? 2 : 1 ; ?>" style="<?php echo $r['type']=='volumes' ? 'display:none;color:#999' : ''; ?>" align="center">
                        <td>
                            <?php if( $r['type'] != 'volumes' ){?>
                            <input type="checkbox" name="listtable-dbbackup-ids" value="<?php e($r['file'],'formc'); ?>" class="checkbox" 
                            onclick="ListTable.mchoice(this,'<?php e($r['file'],'hstr'); ?>');Formc.cbgSyncCb(Formc.cbgByName(this.name),'listtable-dbbackup-touch')"/>
                            <?php }?>
                        </td>
                        <td align="left"><?php echo $r['name']; ?></td>
                        <td><?php echo $r['date']; ?></td>
                        <td><?php echo bitunit($r['size']); ?></td>
                        <td><?php echo $r['vol']; ?></td>
                        <td class="action"><?php echo $r['acts']; ?></td>
                    </tr>
                    <?php }}else{?>
                    <tr><td colspan="6"><div class="tips-div"><span>无数据</span></div></td></tr>
                    <?php }?>
                <?php }?>
                </table>

                <div class="listtable-footer">
                    <?php if( !empty($tpl['all']) ){?>
                    <div class="action">
                        <div class="hddl" onmouseover="this.className+=' hddlon'" onmouseout="this.className='hddl'">
                            <a href="javascript:void(0)" onclick="ListTable.achoice(-1,'listtable-dbbackup-touch','listtable-dbbackup-ids')">选择<span>&nbsp;</span></a><div>
                                <a href="javascript:void(0);" onclick="ListTable.achoice(1,'listtable-dbbackup-touch','listtable-dbbackup-ids')">全选</a>
                                <a href="javascript:void(0);" onclick="ListTable.achoice(-1,'listtable-dbbackup-touch','listtable-dbbackup-ids')">反选</a>
                                <a href="javascript:void(0);" onclick="ListTable.achoice(0,'listtable-dbbackup-touch','listtable-dbbackup-ids')">不选</a></div>
                        </div>
                        <a href="javascript:void(0)" onclick="ListTable.batch(this,'?act=del',{'confirm':'确认删除？'})">删除</a>
                    </div>
                    <?php }?>
                </div>

        <?php if( $tpl['_bodysub'] != 'query' ){?>
            </div>
        </div>
        <?php }?>

    <?php if( $tpl['_body'] == 'index' ){?>
        <div style="display:none">
            <form onsubmit="ajax_form_init(this,'modules/db/db_backup.php?act=upload',{'complete':deal_dbbackup_upload});">
                <div class="table-header"><i></i><span>请上传扩展名为.sql , 容量小于2048 KB 的文件</span></div>
                <div class="form-div" style="border-bottom:0;">
                    <table class="form-table" cellspacing="1">
                    <tr>
                        <td width="95"><h1>本地SQL文件：</h1></td>
                        <td><?php echo $tpl['cbox_file']; ?></td>
                    </tr>
                    </table>
                </div>
            </form>
        </div>	
    </div>
    <?php }?>


<?php } ?>